package com.xjgc.convert.param;

import com.alibaba.fastjson.JSON;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamImplicit;
import com.thoughtworks.xstream.io.xml.StaxDriver;
import com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder;
import com.xjgc.msi.biz.entity.XmCee;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 转换参数
 * @author: 小逗号
 * @date: 2023-12-29
 * @description:
 * @since:
 */
@Data
public class ConvertParam2 implements Serializable {
    private List itemList;


    public static void main(String[] args) {
        XStream xStream = new XStream(new StaxDriver(new XmlFriendlyNameCoder("_-", "_")));
        //忽略未知标签
        xStream.ignoreUnknownElements();
        //开启注解扫描,指定扫描Class

//        xStream.processAnnotations(ConvertParam2.class);
        xStream.processAnnotations(new Class[]{ConvertParam2.class,XmCee.class});
        xStream.alias("REQUEST_DATA", ConvertParam2.class);
        xStream.addImplicitCollection(ConvertParam2.class,"itemList","ITEM",XmCee.class);

        //        xStream.alias("REQUEST_DATA",ConvertParam.class);
//        xStream.addImplicitCollection(ConvertParam.class,"itemList",param.tClass);
//        xStream.processAnnotations(new Class[]{ConvertParam.class,param.tClass});
        System.out.println("=============================");
        Object o = xStream.fromXML(xml);
        System.out.println(o);
        System.out.println("=============================");
        System.out.println(JSON.toJSONString(o));
    }



    static String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
            "<REQUEST_DATA><ITEM><PROJECT_CODE>116230001</PROJECT_CODE><HISTORY_CODE/>" +
            "<PROJECT_NAME>测试项目</PROJECT_NAME><PROJECT_CLASSIFICATION>1</PROJECT_CLASSIFICATION>" +
            "<PROJECT_CLASSIFICATION_NAME>投资项目</PROJECT_CLASSIFICATION_NAME>" +
            "<UNDERTAKING_ORGANIZATION>16000117</UNDERTAKING_ORGANIZATION>" +
            "<UNDERTAKING_ORGANIZATION_ADMINISTRATIVE_ORGANIZATION_FULL_NAME>二级单位</UNDERTAKING_ORGANIZATION_ADMINISTRATIVE_ORGANIZATION_FULL_NAME>" +
            "<UNDERTAKING_ORGANIZATION_ADMINISTRATIVE_ORGANIZATION_FEATURE_CODE>平高集团有限公司</UNDERTAKING_ORGANIZATION_ADMINISTRATIVE_ORGANIZATION_FEATURE_CODE>" +
            "<PROJECT_LEADER>12001219</PROJECT_LEADER><PROJECT_LEADER_NAME>ceshi2</PROJECT_LEADER_NAME><PROJECT_APPROVAL_YEAR>2023</PROJECT_APPROVAL_YEAR>" +
            "<SCHEDULED_STAR_TIME>2023-11-28</SCHEDULED_STAR_TIME><SCHEDULED_END_TIME>2023-12-01</SCHEDULED_END_TIME><GENERAL_BUDGET>100000.0000</GENERAL_BUDGET>" +
            "<PARENT_PROJECT/><PARENT_PROJECT_PROJECT_NAME>上级项目_项目名称</PARENT_PROJECT_PROJECT_NAME><DOMESTIC_OVERSEAS>1</DOMESTIC_OVERSEAS>" +
            "<DOMESTIC_OVERSEAS_NAME>境内</DOMESTIC_OVERSEAS_NAME><MAIN_NON_MAIN_BUSINESS>1</MAIN_NON_MAIN_BUSINESS>" +
            "<MAIN_NON_MAIN_BUSINESS_NAME>主业</MAIN_NON_MAIN_BUSINESS_NAME><FIXED_ASSETS_INVESTMENT>120000.0000</FIXED_ASSETS_INVESTMENT>" +
            "<ADD_APPEND>1</ADD_APPEND><ADD_APPEND_NAME>新增</ADD_APPEND_NAME><HOLDING_PARTICIPATING>1</HOLDING_PARTICIPATING>" +
            "<HOLDING_PARTICIPATING_NAME>控股</HOLDING_PARTICIPATING_NAME><IS_IT_A_PROJECT_OF_THE_PROJECT_COMPANY>1</IS_IT_A_PROJECT_OF_THE_PROJECT_COMPANY>" +
            "<IS_IT_A_PROJECT_OF_THE_PROJECT_COMPANY_NAME>项目公司项目</IS_IT_A_PROJECT_OF_THE_PROJECT_COMPANY_NAME><RETAIL_CLASSIFICATION>2</RETAIL_CLASSIFICATION>" +
            "<RETAIL_CLASSIFICATION_NAME>生产管理用工器具</RETAIL_CLASSIFICATION_NAME><IS_IT_A_STRATEGIC_EMERGING_INDUSTRY>0</IS_IT_A_STRATEGIC_EMERGING_INDUSTRY>" +
            "<IS_IT_A_STRATEGIC_EMERGING_INDUSTRY_NAME>否</IS_IT_A_STRATEGIC_EMERGING_INDUSTRY_NAME><PROVINCE>12</PROVINCE><PROVINCE_NAME>天津市</PROVINCE_NAME>" +
            "<INDUSTRIAL_SECTOR>1</INDUSTRIAL_SECTOR><INDUSTRIAL_SECTOR_NAME>智慧电气</INDUSTRIAL_SECTOR_NAME><HEADQUARTERS_MANAGEMENT_LEVEL>1</HEADQUARTERS_MANAGEMENT_LEVEL>" +
            "<HEADQUARTERS_MANAGEMENT_LEVEL_NAME>重大（A）</HEADQUARTERS_MANAGEMENT_LEVEL_NAME><SUBSIDIARY_MANAGEMENT_LEVEL>1</SUBSIDIARY_MANAGEMENT_LEVEL>" +
            "<SUBSIDIARY_MANAGEMENT_LEVEL_NAME>重大（A）</SUBSIDIARY_MANAGEMENT_LEVEL_NAME><PARTICIPATE_ORGANIZATION>16000117</PARTICIPATE_ORGANIZATION>" +
            "<PARTICIPATE_ORGANIZATION_ADMINISTRATIVE_ORGANIZATION_FULL_NAME>二级单位</PARTICIPATE_ORGANIZATION_ADMINISTRATIVE_ORGANIZATION_FULL_NAME>" +
            "<TECHNICAL_FIELD>1</TECHNICAL_FIELD><TECHNICAL_FIELD_NAME>高压变压器</TECHNICAL_FIELD_NAME><NATIONAL_PROJECT_CATEGORY>2</NATIONAL_PROJECT_CATEGORY>" +
            "<NATIONAL_PROJECT_CATEGORY_NAME>国资委科技考核项目</NATIONAL_PROJECT_CATEGORY_NAME><IS_IT_A_LEADER_SELECTION_PROJECT>0</IS_IT_A_LEADER_SELECTION_PROJECT>" +
            "<IS_IT_A_LEADER_SELECTION_PROJECT_NAME>否</IS_IT_A_LEADER_SELECTION_PROJECT_NAME><IS_IT_A_MILITARY_ORDER_PROJECT>0</IS_IT_A_MILITARY_ORDER_PROJECT>" +
            "<IS_IT_A_MILITARY_ORDER_PROJECT_NAME>否</IS_IT_A_MILITARY_ORDER_PROJECT_NAME><IS_IT_A_HORSE_RACING_PROJECT>1</IS_IT_A_HORSE_RACING_PROJECT>" +
            "<IS_IT_A_HORSE_RACING_PROJECT_NAME>是</IS_IT_A_HORSE_RACING_PROJECT_NAME><UPPER_LOWER_LIMIT>2</UPPER_LOWER_LIMIT>" +
            "<UPPER_LOWER_LIMIT_NAME>限下</UPPER_LOWER_LIMIT_NAME><CAPITAL_COST>1</CAPITAL_COST><CAPITAL_COST_NAME>资本性</CAPITAL_COST_NAME>" +
            "<TYPE_OF_CONSTRUCTION_PROJECT>1</TYPE_OF_CONSTRUCTION_PROJECT><TYPE_OF_CONSTRUCTION_PROJECT_NAME>研发设计类</TYPE_OF_CONSTRUCTION_PROJECT_NAME>" +
            "<DATAID>943582db5dd548228848094c7e7a1b9f</DATAID><DATASTATUS>1</DATASTATUS><STOPREASON/><CREATEDATE>2023-11-28 17:04:49</CREATEDATE>" +
            "<CREATEUSER>admin</CREATEUSER><CREATEDEPT>001</CREATEDEPT><VALIDDATE>2023-11-28 17:05:15</VALIDDATE><MODIFYUSER>admin</MODIFYUSER>" +
            "</ITEM></REQUEST_DATA>\n";

}
